/* dsp_test.h */
#ifndef _DSP_TEST_H_
#define _DSP_TEST_H_

#define MAX_DLTAP	32

//delay line
typedef struct {
	float *			delayline;
	unsigned int 	lenght;
	unsigned int 	curpos;
} DSPdelayLine;

//tapped delay line
typedef struct {
	float *			delayline;
	unsigned int 	maxlen;
	unsigned int 	curpos[MAX_DLTAP];
	int			 	tap_num;
} DSPTPdelayLine;

//all pass
typedef struct {
	float 			g;
	DSPdelayLine dl;
} DSPallPass;

//delay FX
typedef struct {
	float 			mix;
	float			feedback;
	
	DSPdelayLine	dl;
} DSPDelay;

typedef struct {
	float 			drywet;
	DSPallPass		ap[3];
	DSPTPdelayLine	tdl;

	float 			ffcf_g[4];
} DSPjcReverb;

typedef short SType;

//audio slot get/put
void get_LR_itof(const SType * restrict in, float * restrict out_L, float * restrict out_R, int n);
void put_LR_ftoi(const float * restrict in_L, const float * restrict in_R, SType * restrict out, int n);
void get0_itof(const SType *in, float *out, int n);
void get1_itof(const SType *in, float *out, int n);
void put0_ftoi(const float *in, SType *out, int n);
void put1_ftoi(const float *in, SType *out, int n);

//misc
void dspBufClear(float *buf, unsigned int len);

//basic blocks
//delay line
void 	dspDelayLineInit(DSPdelayLine *dl, float *delayline, unsigned int lenght);
float dspDelayLineGet(DSPdelayLine *dl);
void  dspDelayLinePut(DSPdelayLine *dl, float in);

//tapped delay line
void 	dspTPDelayLineInit(DSPTPdelayLine *tdl, float *delayline, unsigned int *del, int n_tap);
void	dspTPDelayLineGet(DSPTPdelayLine *tdl, float *out);
void	dspTPDelayLinePut(DSPTPdelayLine *tdl, float in);


//allpass
void	dspAllPassInit(DSPallPass *ap, float *delayline, float g, unsigned int n);
float dspAllPassTick(DSPallPass *ap, float in);

//delay
void dspDelayInit(DSPDelay *del, float *delayline, unsigned int lenght, float mix, float feedback);
void dspDelay(DSPDelay *del, const float *in, float *out, int size);

//reverb
void dspJCRevInit(DSPjcReverb *rev, float drywet, float *ap_delayline[3], float ap_g[3], unsigned int ap_n[3], float *ffcf_delayline, float ffcf_g[4], unsigned int ffcf_n[4]);
void dspJCReverb(DSPjcReverb *rev, const float *input, float *output, int size);  

#endif
